<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title></title>
	</head>
	<body>
		<script type="text/javascript">
			var arr = [20,51,61,40,34];
			for (var i = 0; i < arr.length -1; i++){	/*i等于0,i小于5个数值减一*/
				for (var j = 0; j < arr.length -1 - i; j++){	/*j等于0，j小于总数值减一减上一个i的值*/
					if (arr[j] > arr [j + 1]){	/*判断20大于51*/
						var laji = arr[j];	/*laji等于20*/
						arr[j] = arr[j + 1];	/**/
						arr[j + 1] = laji;
					}
				}
			}
			document.write(arr);
		</script>
	</body>
</html>
